<?php

Yii::import('common.models._base.BaseGifttofriendWorkshop');

class GifttofriendWorkshop extends BaseGifttofriendWorkshop {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public static function saveGifttofriendWorkshopdetails($purchaseOrderModel, $emailId) {        
      $transaction_id=$purchaseOrderModel->transaction_id;
        $order_date_time=$purchaseOrderModel->order_date_time;
        $model = new GifttofriendWorkshop();
        $model->setAttribute('gift_to_user_email', $emailId);
        $model->setAttribute('purchase_order_id', $purchaseOrderModel->id);
        $model->save();
        Yii::app()->runController('/shoppingCart/sendmailtogiftuser/purchaseId/' . $purchaseOrderModel->id . '/emailId/' . $emailId.'/transaction_id/' . $transaction_id . '/order_date_time/' . $order_date_time);
        return true;
    }
    public static function giftClassTousers($id){
        $giftusername='';
      $model= GifttofriendWorkshop::model()->findAll('purchase_order_id='.$id);
      if(!empty( $model)){
          foreach ($model as  $model){
            $giftusername.=  $model->gift_to_user_email;
          }
      }
      return (!empty($giftusername))?$giftusername:'--';
    }
    
}